home *** CD-ROM | disk | FTP | other *** search
- Path: rain.fr!world-net!usenet
- From: Frederic LACHASSE <lachass@worldnet.fr>
- Newsgroups: comp.lang.c++
- Subject: Re: timing question under MSVC++
- Date: Mon, 29 Jan 1996 19:14:08 +0000
- Organization: World-Net information exchange, Internet provider.
- Message-ID: <VA.00000011.0038ecde@fred>
- References: <4eeoul$g1e@news.ust.hk>
- Reply-To: lachass@worldnet.fr
- NNTP-Posting-Host: client44.sct.fr
- X-Newsreader: Virtual Access by Ashmount Research Ltd, http://www.ashmount.com
-
- >
- > I've tried to use <time.h> to find out how fast my program is.
- Strangly,
- > everytime I compile it with exactly the same compiler options and
- then run it
- > with the same inputs, the timing result can still be different. The
- difference
- > ranges from 1/100 secs to 1/10 secs. I'm confused. My input was come
- from the
- > hard disc.
- >
-
- Lots of reason, mostly because of disk I/O:
-
- - One of the delay in disk I/O is time when its arm goes from the
- current cylinder to the one needed. That can be as long as twice the
- average time (if you must cross all cylinders) to 0 (you just happen to
- be on the right one).
-
- - To accelerate disk I/O, Windows uses the SmartDrive utility to keep
- the latest block from disks in cache memory. Typical configuration has
- about 2MB of memory used that way. Reading a block that is already in
- cache memory can be thousands of times faster than getting it from
- disk. So when reading a second time a file (i.e. while re-executing the
- program), it's generally faster, given that the file isn't too big
- (the program executable plus the file can both stay in cache memory).
-
- There's other factors that can change timing randomly, but to a lesser
- degree than I/O operations, so they can be ignored in that case.
-
- Frederic LACHASSE (ECP 86)
- CompuServe: 100530,2005
- Internet: lachass@worldnet.fr
-
-